<template>
<div class="topoAlarm">

</div>
</template>

<script>
export default {
  data: function() {
    return {
      testData:[{
        "title":"警告",
        "type":"warning",
        "content":"出口流量超限[GigabitEthernet 1/15"
      },
      {
          "title":"严重问题",
        "type":"error",
        "content":"出口流量超限[VLAN 192"
      },{
          "title":"严重问题",
        "type":"error",
        "content":"入口流量超限VLAN 109"
      },{
        "title":"警告",
        "type":"warning",
        "content":"出口流量超限[GigabitEthernet 2/29"
      },{
        "title":"警告",
        "type":"warning",
        "content":"出口流量超限[GigabitEthernet 1/13"
      },
      {
        "title":"严重问题",
        "type":"error",
        "content":"出口流量超限[VLAN 1000"
      }
    ]
    };
  },
  methods: {
    addMessage(obj){
      var self = this;
      this.$notify({
          title: obj.title,
          message: obj.content,
          type: obj.type,
          onClick:function(){
            self.$router.push('/alarm/handle');
          }
        });
    }
  },
  mounted: function() {
    var self = this;
    self.timerId = setInterval(function() {
      if($(".topoAlarm").length == 0){
        clearInterval(self.timerId);
      }else{
          var index = parseInt(6*Math.random());
          if(index-2>0){
            self.addMessage(self.testData[index]);
          }
      }
    }, 5000);
  }
}
</script>
